#include <stdio.h>
#include "ofc/DJPEGImage.h"
#include "ofc/DFile.h"

int main(int argc, char *argv[])
{
#ifdef HAVE_DJPEGIMAGE 
  DJPEGImage *image = [DJPEGImage new];
  DFile      *file  = [DFile new];

  char       name[] = "example.jpg";

  if ([file open :name :"rb"])
  {
    if ([DJPEGImage isImage :file])
    {
      if ([image open :file])
      {
        printf("\"%s\" is a JPEG image with width:%d height:%d BytesPerPixel:%d Images:%d\n",
            name, [image width], [image height], [image bytesPerPixel], [image images]);
        
        [image close];
      }
      else
        printf("Could not open image \"%s\".\n", name);
    }
    else
      printf("\"%s\" is not a JPEG image.\n", name);

    [file close];
  }
  else
    printf("Could not find \"%s\":%d\n", name, [file error]);

  [image free];                        // Cleanup
  [file  free];
#else
  printf("DJPEGImage is not present in the library.\n");
#endif
  return 0;
}

